

module.exports = (url, data, method = 'GET', header = {}) => {
    // wx.showLoading({ title: 'Loading...' })
    // var baseUrl = "https://shop.tj564.com/";÷
  var baseUrl = "https://jw.handecms.com/";
  // var baseUrl = "http://localhost/shop/public/index.php/";

    console.log(url.indexOf("http"));
    if(url.indexOf("http") != 0){
        url = baseUrl+url;
    }
    // 调试用
  // url = "http://localhost/shop/public/index.php/"+url;
    console.log(url);
    return new Promise((resolve, reject) => {
      wx.request({
        url: url,
        data,
        header,
        method,
        dataType: 'json',
        success: resolve,
        fail: reject,
        complete: wx.hideLoading
      })
    })
  }